<?php $this->_extends('_layouts/main_layout'); ?>
<?php $this->_block('title'); ?>
	Setup Landing Urls
<?php $this->_endblock(); ?>

<?php $this->_block('contents'); ?>
<div id="content" class="box">
	<h1>Setup Landing Urls</h1>
		<?php if (isset($infos)) 
				{
					foreach ($infos as $info)
					{
		?>
				<p class="msg info"><?php echo $info;?></p>
		<?php		}
				}
		?>
		<fieldset>
			<legend>Setup Landing Urls</legend>
		<?php if (isset($errors)) 
				{
					foreach ($errors as $error)
					{
		?>
				<p class="msg error"><?php echo $error;?></p>
		<?php		}
				}
		?>
	<form method="post" action="<?php echo url('offer/landingurls'); ?>">
		<input type="hidden" name="offer_id" value="<?php echo $offer_id; ?>" />
		<?php 
			if(null != $landingurls){
				
		?>
		<table>
		<tr>
			<th>Url</th>
			<th>Weight</th>
			<th></th>
		</tr>
		<?php 
			
			$num = count($landingurls);
			for($i = 0; $i < $num; $i++):
		 ?>
		<?php  $flag = (null !== $landingurls[$i]['o_id'] && $offer_id == $landingurls[$i]['o_id']);   ?>
		<tbody>
			<tr>
					<td>
						<label><a href="<?php echo $landingurls[$i]['url']; ?>" target="_blank"><?php echo $landingurls[$i]['url']; ?></a></label>
					</td>
					<td>
						<input type="text" name="landingurls[<?php echo $i ;?>][weight]" value="<?php echo $flag ? $landingurls[$i]['weight'] : '1'; ?>"/>
					</td>
					<td>
						<input type="checkbox" name="landingurls[<?php echo $i ;?>][id]" value="<?php echo $landingurls[$i]['lu_id'];?>"
							 <?php echo $flag ? 'checked="checked"' : '' ; ?> />
					</td>
			</tr>		
			<?php 		
					endfor;
				}else{
					echo '<tr><a href="' . url('landingurl/add') . '">Add new Landing Urls</a><br/><tr>';
				}
			?>
		</tbody>
		</table>
		<input type="submit" value="Setup"/>
	</form>
	</fieldset>
</div>
<?php $this->_endblock(); ?>